<template>
  <div class="order-meal box">
    <h3>商品费用</h3>
    <div class="business" @click="handleBusiness">
      {{ orderDetail.businessName }}
    </div>
    <div class="list">
      <div class="item" v-for="item in orderDetail.orderDetailList" :key="item.id">
        <img :src="item.image" />
        <div class="info">
          <span class="name">
            {{ item.name }}
          </span>
          <span v-if="item.dishFlavor" style="color: #999; font-size: 12px"> 口味:{{ item.dishFlavor }} </span>
          <div class="amount">
            <span class="number">×{{ item.number }}</span>
            <span><i style="font-size: 12px">￥</i>{{ item.amount }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="expense">
      <div class="item">
        <span>打包费</span>
        <span>￥{{ orderDetail.packAmount }}</span>
      </div>
      <div class="item">
        <span>配送费</span>
        <span>￥{{ orderDetail.deliveryAmount }}</span>
      </div>
    </div>
    <div class="total">
      <h1>总计</h1>
      <span>￥{{ orderDetail.amount }}</span>
    </div>
  </div>
</template>
<script setup lang="ts">
import type { OrderDetailResult } from '@/types/order'
import { useRouter } from 'vue-router'
const props = defineProps<{
  orderDetail: OrderDetailResult
}>()
const router = useRouter()
const handleBusiness = () => {
  router.push({
    path: '/business',
    query: { id: props.orderDetail.businessId },
  })
}
</script>
<style scoped lang="scss">
.order-meal {
  padding: 10px;
}

.business {
  margin: 10px 0;
  font-size: var(--font-size-medium);
}
.list {
  height: auto;
  max-height: 180px;
  overflow-y: scroll;
  display: flex;
  flex-direction: column;
}
.item {
  display: flex;
  margin: 5px 0;
  img {
    width: 60px;
    height: 60px;
    border-radius: 5px;
  }
}
.info {
  flex: 1;
  margin-left: 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  .amount {
    display: flex;
    justify-content: space-between;
  }
}
.expense .item,
.total {
  display: flex;
  justify-content: space-between;
  margin: 10px 0;
}
</style>
